package context;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component(value = "listener")
// 自定义应用程序监听器
public class CustomApplicationListener implements ApplicationListener<ApplicationEvent> {
    @Override
    // 触发应用程序事件时
    public void onApplicationEvent(ApplicationEvent applicationEvent) {
        if (applicationEvent instanceof CustomApplicationEvent) {
            System.out.println("监测到自定义事件：" + applicationEvent.getSource());
        }
    }
}
